<template>
        <div id="selectProject">
            <header>
                <i @click="goBack()"></i>
                <div>选择项目</div>
                <span @click='finish'>完成</span>
            </header>
            <div>
                <ul>
                    <h3>
                        修复
                    </h3>
                    <li>           
                        <label>
                            <i>备牙</i>
                            <input type="checkbox" v-model="project" value="备牙">
                            <span></span>
                        </label>	        
                    </li>
                    <li>           
                        <label>
                            <i>戴牙</i>
                            <input type="checkbox" v-model="project" value="戴牙">
                            <span></span>
                        </label>	        
                    </li>
                    <li>           
                        <label>
                            <i>室内冠</i>
                            <input type="checkbox" v-model="project" value="室内冠">
                            <span></span>
                        </label>	        
                    </li>
                </ul>
                <ul>
                    <h3>
                        定期复诊
                    </h3>
                    <li>           
                        <label>
                            <i>常规检查</i>
                            <input type="checkbox" v-model="project" value="常规检查">
                            <span></span>
                        </label>	        
                    </li>
                </ul>
                <ul>
                    <h3>
                        牙周
                    </h3>
                    <li>           
                        <label>
                            <i>牙周上药</i>
                            <input type="checkbox" v-model="project" value="牙周上药">
                            <span></span>
                        </label>	        
                    </li>
                    <li>           
                        <label>
                            <i>牙周刮治</i>
                            <input type="checkbox" v-model="project" value="牙周刮治">
                            <span></span>
                        </label>	        
                    </li>
                </ul>
            </div>
            
        </div>
    </template>
    <script>
        export default {
            data() {
                return {
                   project: [],
                }
            },
            methods: {
                //返回上一级
                goBack() {
                    this.$router.back();
                    // this.$router.push({name:'timing'});
                   
                    this.project = this.$route.query.project.split(',');
        
                    this.$router.push({name:'addNewAppointment',query: {project:this.project}});
                  
                    this.$router.push({name:'addNewAppointment',query: {project:this.project}});
                },
                init() {
                    if(this.$route.query.project) {
                        console.log(this.$route.query.project.split(','));
                        this.project = this.$route.query.project.split(',');
                    }
                    
                },
                //完成
                finish() {          
                    if(this.project.length) {
                        const from = this.$route.query.from;
                        const from0 = this.$route.query.from0;
                        this.$router.push({name: from,query:{from: from0,project:this.project}});
                    }else {
                        this.$utils._toast("未选择项目");
                    }
                    console.log(this.project);
                    
                }
                
            },
            created() {
                this.init();
                
            }
        }
    
    </script>
    <style lang="scss" scoped>
    
    </style>